Evaluation of UTOPIA's performance in predicting MPs size dristributionsusing the monaco Monte Carlo framework¶

(https://monaco.readthedocs.io/en/latest/)¶

With this script we preform an evaluation of UTOPIA's size distribution predictive capacity by comparing predicted size distributions in targeted compartmanes aginst observed MPs size distributions reported in the compilation of published datasets by Kooi et al.

Import the necessary libraries¶

In [16]:
from utopia.monte_carlo.montecarlo_analysis_paper import run_mc_analysis_paper, set_emission, sim_to_dataframe, reshape_mc_results
from utopia.monte_carlo.monte_carlo_helpers import *
from utopia.utopia import utopiaModel
import numpy as np
import scipy.stats as st
import pandas as pd

Load the UTOPIA's default configuration parameters¶

In [17]:
data_data = utopiaModel.load_json_file("data/default_data.json")
config_data = utopiaModel.load_json_file("data/default_config.json")

Define the parameter distributions for the Monte Carlo simulation.¶

Transform the discrete distributions to continuous distributions for compatibility with the current montecarlo function

In [4]:
import numpy as np
# To reproduce Rakesh results, use these following discrete values to then generate distributions (lognormal and uniform) from which to sample:

# Plastic density (mpdensity): [900, 1100, 1500] kg/m³ 
# Fragmentation style (FI): [0, 0.3, 0.5, 0.7, 1.0] - ranging from more erosive to more explosive fragmentation 
# Discorporation half time (thalf_deg): [316,1000,10000, 31600, 100000] days 
# Fragmentation timescale (thalf_frag): [10, 31.6, 100, 316] days
# your discrete support values

vals_density = np.array([900, 1100, 1500])
vals_FI = np.array([0, 0.3, 0.5, 0.7, 1.0])
vals_deg = np.array([316, 1000, 10000, 31600, 100000])
vals_frag = np.array([10, 31.6, 100, 316])

def lognorm_params_from_values(values, sigma):
    """
    Return (s, scale) for scipy.stats.lognorm given target values.
    sigma = shape parameter (spread in log space).
    We center the lognormal at the geometric mean of the values.
    """
    mu = np.mean(np.log(values))  # geometric mean in log-space
    scale = np.exp(mu - (sigma**2) / 2)
    return sigma, scale

# choose sigma to control spread (tune manually!)
s_deg, scale_deg = lognorm_params_from_values(vals_deg, sigma=0.5)
s_frag, scale_frag = lognorm_params_from_values(vals_frag, sigma=0.8)
s_density, scale_density = lognorm_params_from_values(vals_density, sigma=0.1)
s_FI, scale_FI = lognorm_params_from_values(vals_FI[vals_FI > 0], sigma=0.5)  # avoid zero for lognorm

param_distributions = {
    "MPdensity_kg_m3": ("lognorm", {"s": s_density, "scale": scale_density}),
    "FI": ("uniform", {"loc": 0.0, "scale": 1.0}),
    "t_half_deg_free": ("lognorm", {"s": s_deg, "scale": scale_deg}),
    "t_frag_gen_FreeSurfaceWater": ("lognorm", {"s": s_frag, "scale": scale_frag})
}
In [5]:
# Visualise the distributions by plotting

for psrsm in param_distributions:
    plot_distribution_from_dict(psrsm, param_distributions)
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [6]:
# Recent studies have challenged the density of biofilm used here (1388 kg m-3) as being too high. see e.g. # https://doi.org/10.1186/s43591-024-00098-2 
# Consider testing chnages in biofouling density
In [18]:
# Set emission scenarios to run that are compatible for comparison with observations data from Kooi et al.

##############################################
# DEFINE ARTICLE -> EMISSION SCENARIOS
##############################################

overlay_emission_scenarios = {
    "Sea Sediment | Bergmann":["Ocean_Surface_Water","Coast_Surface_Water","Coast_Column_Water"],
    "Sea Surface all | Cai":["Surface_Freshwater","Coast_Surface_Water","Impacted_Soil_Surface"],
    "Sea Surface Fragments | Enders":["Ocean_Surface_Water","Coast_Surface_Water"],
    "Sea Surface Fibers | Enders":["Ocean_Surface_Water","Coast_Surface_Water"],
    "Fragments in water | Eo":["Impacted_Soil_Surface","Surface_Freshwater"],
    "Fibers in water | Eo":["Impacted_Soil_Surface","Surface_Freshwater"],
    "Fragments in sediment | Eo":["Impacted_Soil_Surface","Surface_Freshwater"],
    "Fibers in sediment | Eo":["Impacted_Soil_Surface","Surface_Freshwater"],
    "Sea Surface all | Erni-Cassola":["Coast_Surface_Water","Impacted_Soil_Surface"],
    "Fresh water sediments | Imhof":["Surface_Freshwater","Impacted_Soil_Surface"],
    "Sea Surface all | Isobe L1":["Surface_Freshwater","Coast_Surface_Water"],
    "Sea Surface all | Isobe L2":["Surface_Freshwater","Coast_Surface_Water"],
    "Sea Surface all | Isobe L3":["Surface_Freshwater","Coast_Surface_Water"],
    "Sea Surface all | Isobe L4":["Surface_Freshwater","Coast_Surface_Water"],
    "FP all | Scheurer":["Impacted_Soil_Surface"],
    "Sea Surface Fragments | Song":["Impacted_Soil_Surface","Surface_Freshwater"],
    "Sea Surface Fibers | Song":["Impacted_Soil_Surface","Surface_Freshwater"],
    "Sea Surface all | Zhang":["Coast_Surface_Water","Surface_Freshwater"]}
    
    
    
    
# DEFINE ARTICLE->COMPARTMENTS MAPPING
#############################################
overlay_compartments_mapping = {
    "Sea Sediment | Bergmann": ["Sediment_Coast", "Sediment_Ocean"],
    "Sea Surface all | Cai": ["Coast_Surface_Water", "Ocean_Surface_Water"],
    "Sea Surface Fragments | Enders": ["Coast_Surface_Water", "Ocean_Surface_Water"],
    "Sea Surface Fibers | Enders": ["Coast_Surface_Water", "Ocean_Surface_Water"],
    "Fragments in water | Eo": ["Bulk_Freshwater", "Surface_Freshwater"],
    "Fibers in water | Eo": ["Bulk_Freshwater", "Surface_Freshwater"],
    "Fragments in sediment | Eo": ["Sediment_Ocean", "Sediment_Coast", "Sediment_Freshwater"],
    "Fibers in sediment | Eo": ["Sediment_Ocean", "Sediment_Coast", "Sediment_Freshwater"],
    "Sea Surface all | Erni-Cassola": ["Coast_Surface_Water", "Ocean_Surface_Water"],
    "Fresh water sediments | Imhof": ["Bulk_Freshwater", "Surface_Freshwater"],
    "Sea Surface all | Isobe L1": ["Coast_Surface_Water", "Ocean_Surface_Water"], 
    "Sea Surface all | Isobe L2": ["Coast_Surface_Water", "Ocean_Surface_Water"], 
    "Sea Surface all | Isobe L3": ["Coast_Surface_Water", "Ocean_Surface_Water"],
    "Sea Surface all | Isobe L4": ["Coast_Surface_Water", "Ocean_Surface_Water"],
    "FP all | Scheurer": ["Impacted_Soil_Surface", "Sediment_Freshwater"], 
    "Sea Surface Fragments | Song": ["Coast_Surface_Water", "Ocean_Surface_Water"],
    "Sea Surface Fibers | Song": ["Coast_Surface_Water", "Ocean_Surface_Water"],
    "Sea Surface all | Zhang": ["Coast_Surface_Water", "Ocean_Surface_Water"]
}

# NOTE!I have ch anged the mapping for the FP all | Scheurer study compared to the original data from Rakesh. Samples were collected in floodplain soils, so the impacted_soil_surface compartment and freshwater sediment compartment have been included in the compartment mapping.might be more appropriate. Since the model does not simulate floodplain soils as a separate compartment.?

# NOTE 2! Changed entry in overlay compatrments mapping for the "Fragments in sediment | Eo" and "Fibers in sediment | Eo" studies to exclude the beaches compartments. 
In [11]:
# Set emission scenarios according to the mapping defined above to the run the model for each parameter combination using the Monte Carlo framework and perform the comparison with the observed data according to mapping.

Test difference in results if run with distributions or single values for the parameters for one article

In [12]:
import seaborn as sns
import matplotlib.pyplot as plt
from utopia.monte_carlo.montecarlo_analysis_paper import run_and_plot_top_results

MC_simulations_results_all={}
for art in overlay_emission_scenarios.keys():
    print(f"Running Monte Carlo analysis for article: {art}")
    MC_simulations_results=[]
    for comp in overlay_emission_scenarios[art]:
        # Set emissions to that compartment and include it in base_data file
        data_data["emiss_dict_g_s"]= set_emission(data_data["emiss_dict_g_s"].copy(), comp, "e", 100)
        
        
        #Run Monte Carlo analysis for each emission scenario and targer compartment
        for comp_T in overlay_compartments_mapping[art]:
            emission_comp=comp
            target_comp=comp_T
            sim= run_mc_analysis_paper(
            base_config=config_data,
            base_data=data_data,
            param_distributions=param_distributions,
            n_cases=20,art=art,emission_comp=emission_comp,target_comp=target_comp
        )
        
            # Convert sim results to dataframe
            df_MC_results = sim_to_dataframe(sim)
            
            
            MC_simulations_results.append(df_MC_results)
    MC_simulations_results = pd.concat(MC_simulations_results, ignore_index=True)
    input_params=["MPdensity_kg_m3", "FI", "t_half_deg_free", "t_frag_gen_FreeSurfaceWater"]
    tidy_mc_results=reshape_mc_results(MC_simulations_results, input_params, art)
    results_sorted_art = tidy_mc_results.sort_values("RMSE", ascending=True)
    # Keep e.g. top 20 best-fitting combinations
    top_results_art = results_sorted_art.head(20)
    run_and_plot_top_results(top_results_art[0:2],data_data, config_data)
    

    # Correlation heatmap for the top results
    corr = top_results_art[0:20][["MPdensity_kg_m3", "FI", "t_half_deg_free", "t_frag_gen_FreeSurfaceWater"]].corr()

    plt.figure(figsize=(8,6))
    sns.heatmap(corr, annot=True, cmap="coolwarm", center=0)
    plt.title("Correlation matrix (Top 20 best fits)")
    plt.show()
    
    
    MC_simulations_results_all[art]=top_results_art
    
    
        
Running Monte Carlo analysis for article: Sea Sediment | Bergmann
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<?, ? cases/s]
Running cases:  30%|███       | 6/20 [00:14<00:34,  2.48s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:21<00:25,  2.36s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [00:45<00:00,  2.29s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5997.86 cases/s]
Simulation complete! Runtime: 0:00:45.844982
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6665.56 cases/s] 
Running cases:  30%|███       | 6/20 [00:13<00:32,  2.29s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:20<00:26,  2.37s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [00:45<00:00,  2.26s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 30470.79 cases/s]
Simulation complete! Runtime: 0:00:45.169583
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 2414.06 cases/s]
Running cases:  30%|███       | 6/20 [00:12<00:30,  2.17s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:19<00:23,  2.14s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [00:45<00:00,  2.29s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<?, ? cases/s]
Simulation complete! Runtime: 0:00:45.858922
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<?, ? cases/s]
Running cases:  30%|███       | 6/20 [00:13<00:30,  2.21s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:19<00:23,  2.14s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [00:43<00:00,  2.16s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<?, ? cases/s]
Simulation complete! Runtime: 0:00:43.172311
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6670.86 cases/s]
Running cases:  30%|███       | 6/20 [00:12<00:28,  2.06s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:18<00:22,  2.06s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [00:40<00:00,  2.01s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 7577.10 cases/s]
Simulation complete! Runtime: 0:00:40.316425
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6996.34 cases/s] 
Running cases:  30%|███       | 6/20 [00:12<00:28,  2.04s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:18<00:21,  1.97s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [00:39<00:00,  1.99s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5866.98 cases/s] 
Simulation complete! Runtime: 0:00:39.911975

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Cai
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6617.19 cases/s]
Running cases: 100%|██████████| 20/20 [00:46<00:00,  2.34s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 10001.92 cases/s]
Simulation complete! Runtime: 0:00:46.848204
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<?, ? cases/s]
Running cases: 100%|██████████| 20/20 [00:47<00:00,  2.37s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 9986.44 cases/s]
Simulation complete! Runtime: 0:00:47.376523
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5671.43 cases/s]
Running cases: 100%|██████████| 20/20 [00:44<00:00,  2.22s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4584.44 cases/s]
Simulation complete! Runtime: 0:00:44.439927
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 9991.20 cases/s]
Running cases: 100%|██████████| 20/20 [00:43<00:00,  2.19s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<?, ? cases/s]
Simulation complete! Runtime: 0:00:43.766181
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 8256.50 cases/s]
Running cases: 100%|██████████| 20/20 [00:41<00:00,  2.08s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4951.37 cases/s]
Simulation complete! Runtime: 0:00:41.710406
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<?, ? cases/s]
Running cases: 100%|██████████| 20/20 [00:41<00:00,  2.09s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4453.26 cases/s] 
Simulation complete! Runtime: 0:00:41.845000

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface Fragments | Enders
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6448.31 cases/s]
Running cases: 100%|██████████| 20/20 [00:43<00:00,  2.20s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 7738.57 cases/s]
Simulation complete! Runtime: 0:00:43.992502
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 10011.47 cases/s]
Running cases: 100%|██████████| 20/20 [00:53<00:00,  2.66s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4688.73 cases/s]
Simulation complete! Runtime: 0:00:53.302327
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5004.24 cases/s] 
Running cases: 100%|██████████| 20/20 [00:42<00:00,  2.12s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<?, ? cases/s]
Simulation complete! Runtime: 0:00:42.482305
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5490.29 cases/s] 
Running cases: 100%|██████████| 20/20 [00:41<00:00,  2.08s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 2286.60 cases/s]
Simulation complete! Runtime: 0:00:41.710774

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface Fibers | Enders
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6062.45 cases/s] 
Running cases: 100%|██████████| 20/20 [00:52<00:00,  2.63s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 1855.31 cases/s]
Simulation complete! Runtime: 0:00:52.536643
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<?, ? cases/s]
Running cases: 100%|██████████| 20/20 [00:56<00:00,  2.82s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6639.18 cases/s]
Simulation complete! Runtime: 0:00:56.359340
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4540.27 cases/s]
Running cases: 100%|██████████| 20/20 [00:54<00:00,  2.70s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5690.66 cases/s]
Simulation complete! Runtime: 0:00:54.034651
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6429.04 cases/s] 
Running cases: 100%|██████████| 20/20 [01:02<00:00,  3.15s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 7932.49 cases/s]
Simulation complete! Runtime: 0:01:02.951710

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fragments in water | Eo
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4810.26 cases/s]
Running cases: 100%|██████████| 20/20 [00:58<00:00,  2.92s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5979.90 cases/s]
Simulation complete! Runtime: 0:00:58.355775
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3294.43 cases/s]
Running cases: 100%|██████████| 20/20 [00:59<00:00,  2.97s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 9999.53 cases/s] 
Simulation complete! Runtime: 0:00:59.462024
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6672.45 cases/s]
Running cases: 100%|██████████| 20/20 [00:56<00:00,  2.81s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6157.23 cases/s]
Simulation complete! Runtime: 0:00:56.327789
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5686.81 cases/s] 
Running cases: 100%|██████████| 20/20 [00:57<00:00,  2.89s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5242.22 cases/s]
Simulation complete! Runtime: 0:00:57.831758

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fibers in water | Eo
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5003.05 cases/s]
Running cases: 100%|██████████| 20/20 [00:56<00:00,  2.84s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 1716.97 cases/s]
Simulation complete! Runtime: 0:00:56.934235
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5003.05 cases/s]
Running cases: 100%|██████████| 20/20 [00:53<00:00,  2.66s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 19854.69 cases/s]
Simulation complete! Runtime: 0:00:53.153028
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6228.55 cases/s]
Running cases: 100%|██████████| 20/20 [00:52<00:00,  2.64s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6191.77 cases/s]
Simulation complete! Runtime: 0:00:52.885237
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6676.17 cases/s]
Running cases: 100%|██████████| 20/20 [00:52<00:00,  2.65s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6659.74 cases/s]
Simulation complete! Runtime: 0:00:52.989302

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fragments in sediment | Eo
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3969.44 cases/s]
Running cases:  30%|███       | 6/20 [00:15<00:37,  2.69s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:23<00:29,  2.65s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [00:52<00:00,  2.63s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4455.63 cases/s]
Simulation complete! Runtime: 0:00:52.630852
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4417.38 cases/s]
Running cases:  30%|███       | 6/20 [00:16<00:39,  2.85s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:25<00:33,  3.00s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [01:03<00:00,  3.17s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5000.96 cases/s]
Simulation complete! Runtime: 0:01:03.370459
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 7765.79 cases/s]
Running cases:  30%|███       | 6/20 [00:18<00:44,  3.14s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [01:02<00:00,  3.14s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6641.81 cases/s] 
Simulation complete! Runtime: 0:01:02.746842
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4238.81 cases/s]
Running cases:  30%|███       | 6/20 [00:18<00:43,  3.14s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:28<00:34,  3.13s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [01:02<00:00,  3.13s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4649.23 cases/s]
Simulation complete! Runtime: 0:01:02.674916
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3977.72 cases/s]
Running cases:  30%|███       | 6/20 [00:19<00:45,  3.22s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:29<00:35,  3.19s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [01:03<00:00,  3.20s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5687.58 cases/s]
Simulation complete! Runtime: 0:01:03.990834
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4989.95 cases/s]
Running cases:  30%|███       | 6/20 [00:18<00:43,  3.14s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [01:05<00:00,  3.29s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4751.14 cases/s]
Simulation complete! Runtime: 0:01:05.921732

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fibers in sediment | Eo
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 2343.51 cases/s]
Running cases:  30%|███       | 6/20 [00:23<00:55,  3.94s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:33<00:37,  3.45s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [01:08<00:00,  3.40s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3612.51 cases/s]
Simulation complete! Runtime: 0:01:08.086630
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6669.27 cases/s]
Running cases:  30%|███       | 6/20 [00:18<00:44,  3.14s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:28<00:35,  3.21s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [01:03<00:00,  3.19s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5173.36 cases/s] 
Simulation complete! Runtime: 0:01:03.757171
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4024.09 cases/s]
Running cases:  30%|███       | 6/20 [00:19<00:44,  3.17s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [01:03<00:00,  3.19s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5681.03 cases/s]
Simulation complete! Runtime: 0:01:03.830703
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4891.03 cases/s]
Running cases:  30%|███       | 6/20 [00:18<00:43,  3.13s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:28<00:34,  3.11s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [01:02<00:00,  3.12s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 2900.32 cases/s]
Simulation complete! Runtime: 0:01:02.363108
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6674.05 cases/s] 
Running cases:  30%|███       | 6/20 [00:18<00:44,  3.14s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases:  45%|████▌     | 9/20 [00:29<00:38,  3.51s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [01:12<00:00,  3.61s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5005.14 cases/s]
Simulation complete! Runtime: 0:01:12.173422
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4309.81 cases/s]
Running cases:  30%|███       | 6/20 [00:18<00:43,  3.10s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [01:03<00:00,  3.16s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6665.03 cases/s] 
Simulation complete! Runtime: 0:01:03.211953

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Erni-Cassola
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4989.95 cases/s]
Running cases: 100%|██████████| 20/20 [01:04<00:00,  3.21s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5681.03 cases/s]
Simulation complete! Runtime: 0:01:04.222335
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4985.50 cases/s]
Running cases: 100%|██████████| 20/20 [01:03<00:00,  3.17s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4953.12 cases/s]
Simulation complete! Runtime: 0:01:03.481616
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5663.00 cases/s]
Running cases: 100%|██████████| 20/20 [00:58<00:00,  2.94s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 7985.35 cases/s] 
Simulation complete! Runtime: 0:00:58.731313
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4982.84 cases/s]
Running cases: 100%|██████████| 20/20 [01:01<00:00,  3.05s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6365.62 cases/s]
Simulation complete! Runtime: 0:01:01.083154

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fresh water sediments | Imhof
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6628.69 cases/s]
Running cases: 100%|██████████| 20/20 [00:54<00:00,  2.70s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5056.73 cases/s] 
Simulation complete! Runtime: 0:00:54.128064
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6674.58 cases/s] 
Running cases: 100%|██████████| 20/20 [00:53<00:00,  2.70s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5664.15 cases/s]
Simulation complete! Runtime: 0:00:54.024356
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 9597.95 cases/s]
Running cases: 100%|██████████| 20/20 [00:57<00:00,  2.86s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4997.98 cases/s]
Simulation complete! Runtime: 0:00:57.298399
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5464.54 cases/s]
Running cases: 100%|██████████| 20/20 [01:05<00:00,  3.27s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3892.08 cases/s]
Simulation complete! Runtime: 0:01:05.362124

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Isobe L1
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4755.72 cases/s]
Running cases: 100%|██████████| 20/20 [01:10<00:00,  3.53s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5598.75 cases/s]
Simulation complete! Runtime: 0:01:10.617718
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4147.23 cases/s]
Running cases: 100%|██████████| 20/20 [01:02<00:00,  3.13s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4080.86 cases/s] 
Simulation complete! Runtime: 0:01:02.640038
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4422.51 cases/s]
Running cases: 100%|██████████| 20/20 [01:02<00:00,  3.10s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4002.20 cases/s]
Simulation complete! Runtime: 0:01:02.079165
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5000.96 cases/s]
Running cases: 100%|██████████| 20/20 [01:03<00:00,  3.19s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4948.74 cases/s]
Simulation complete! Runtime: 0:01:03.855236

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Isobe L2
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 1921.22 cases/s]
Running cases: 100%|██████████| 20/20 [01:10<00:00,  3.51s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4362.02 cases/s]
Simulation complete! Runtime: 0:01:10.220427
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6613.54 cases/s]
Running cases: 100%|██████████| 20/20 [00:53<00:00,  2.69s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6671.92 cases/s]
Simulation complete! Runtime: 0:00:53.929780
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6665.03 cases/s]
Running cases: 100%|██████████| 20/20 [00:54<00:00,  2.71s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6656.57 cases/s]
Simulation complete! Runtime: 0:00:54.140145
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6286.43 cases/s]
Running cases: 100%|██████████| 20/20 [00:54<00:00,  2.72s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6625.03 cases/s] 
Simulation complete! Runtime: 0:00:54.371634

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Isobe L3
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4961.32 cases/s]
Running cases: 100%|██████████| 20/20 [00:54<00:00,  2.72s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4914.82 cases/s]
Simulation complete! Runtime: 0:00:54.342452
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4961.62 cases/s]
Running cases: 100%|██████████| 20/20 [00:58<00:00,  2.90s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4991.14 cases/s]
Simulation complete! Runtime: 0:00:58.049601
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5689.12 cases/s]
Running cases: 100%|██████████| 20/20 [00:57<00:00,  2.87s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5002.45 cases/s]
Simulation complete! Runtime: 0:00:57.452560
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6667.68 cases/s]
Running cases: 100%|██████████| 20/20 [00:54<00:00,  2.72s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5356.37 cases/s] 
Simulation complete! Runtime: 0:00:54.453260

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Isobe L4
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4920.00 cases/s] 
Running cases: 100%|██████████| 20/20 [00:53<00:00,  2.69s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4660.60 cases/s]
Simulation complete! Runtime: 0:00:53.902362
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6549.51 cases/s]
Running cases: 100%|██████████| 20/20 [00:54<00:00,  2.70s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5696.07 cases/s]
Simulation complete! Runtime: 0:00:54.058771
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5691.44 cases/s]
Running cases: 100%|██████████| 20/20 [00:56<00:00,  2.80s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5681.41 cases/s]
Simulation complete! Runtime: 0:00:56.054505
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6647.60 cases/s]
Running cases: 100%|██████████| 20/20 [01:09<00:00,  3.46s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3978.09 cases/s]
Simulation complete! Runtime: 0:01:09.283120

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: FP all | Scheurer
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5000.06 cases/s] 
Running cases: 100%|██████████| 20/20 [01:02<00:00,  3.15s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3524.33 cases/s]
Simulation complete! Runtime: 0:01:02.985278
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4948.16 cases/s]
Running cases:  30%|███       | 6/20 [00:19<00:44,  3.18s/ cases]c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running cases: 100%|██████████| 20/20 [01:03<00:00,  3.15s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4389.41 cases/s]
Simulation complete! Runtime: 0:01:03.090559

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface Fragments | Song
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4732.11 cases/s]
Running cases: 100%|██████████| 20/20 [01:03<00:00,  3.17s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5003.05 cases/s]
Simulation complete! Runtime: 0:01:03.336385
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3326.83 cases/s]
Running cases: 100%|██████████| 20/20 [01:12<00:00,  3.63s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3623.59 cases/s]
Simulation complete! Runtime: 0:01:12.660914
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5663.39 cases/s]
Running cases: 100%|██████████| 20/20 [01:02<00:00,  3.10s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4958.10 cases/s]
Simulation complete! Runtime: 0:01:02.046143
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3648.81 cases/s]
Running cases: 100%|██████████| 20/20 [01:02<00:00,  3.14s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4370.66 cases/s]
Simulation complete! Runtime: 0:01:02.765782

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface Fibers | Song
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3883.44 cases/s]
Running cases: 100%|██████████| 20/20 [01:04<00:00,  3.21s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6621.89 cases/s]
Simulation complete! Runtime: 0:01:04.294293
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5666.83 cases/s]
Running cases: 100%|██████████| 20/20 [01:08<00:00,  3.43s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4441.00 cases/s]
Simulation complete! Runtime: 0:01:08.604103
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3925.60 cases/s] 
Running cases: 100%|██████████| 20/20 [01:07<00:00,  3.36s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5698.40 cases/s]
Simulation complete! Runtime: 0:01:07.294478
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4466.78 cases/s]
Running cases: 100%|██████████| 20/20 [01:03<00:00,  3.17s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3898.96 cases/s]
Simulation complete! Runtime: 0:01:03.490175

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Zhang
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5691.82 cases/s]
Running cases: 100%|██████████| 20/20 [01:04<00:00,  3.22s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 3329.34 cases/s]
Simulation complete! Runtime: 0:01:04.507434
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 4438.89 cases/s]
Running cases: 100%|██████████| 20/20 [01:03<00:00,  3.17s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6644.44 cases/s]
Simulation complete! Runtime: 0:01:03.529143
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 5697.62 cases/s]
Running cases: 100%|██████████| 20/20 [01:00<00:00,  3.02s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<?, ? cases/s]
Simulation complete! Runtime: 0:01:00.345490
Running 'UTOPIA_MC_simulation' Monte Carlo simulation with 20/20 cases...
Drawing random samples for 4 input variables via the 'sobol_random' method... Done
Generating cases... Done
Preprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 6651.82 cases/s]
Running cases: 100%|██████████| 20/20 [00:50<00:00,  2.53s/ cases]
Postprocessing cases: 100%|██████████| 20/20 [00:00<00:00, 11371.30 cases/s]
Simulation complete! Runtime: 0:00:50.569315

No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [13]:
combined_df = pd.concat(MC_simulations_results_all.values(), ignore_index=True)
In [14]:
combined_df
Out[14]:
Case Observed_dataset Emission_Compartment Target_Compartment RMSE R2 Slope Spearman_r Pass_Spearman MPdensity_kg_m3 FI t_half_deg_free t_frag_gen_FreeSurfaceWater
0 108 Sea Sediment | Bergmann Coast_Column_Water Sediment_Ocean 0.306841 -0.542379 -2.655127 -1.0 True 1334.859380 0.269348 2665.785177 31.280483
1 68 Sea Sediment | Bergmann Coast_Surface_Water Sediment_Ocean 0.314419 -0.619506 -2.627525 -1.0 True 1334.859380 0.269348 2665.785177 31.280483
2 100 Sea Sediment | Bergmann Coast_Column_Water Sediment_Ocean 0.319249 -0.669642 -2.453298 -1.0 True 1223.294660 0.054891 6510.335737 18.298327
3 112 Sea Sediment | Bergmann Coast_Column_Water Sediment_Ocean 0.336169 -0.851313 -2.519515 -1.0 True 1170.689441 0.163532 10975.160488 41.971349
4 72 Sea Sediment | Bergmann Coast_Surface_Water Sediment_Ocean 0.342700 -0.923945 -2.492947 -1.0 True 1170.689441 0.163532 10975.160488 41.971349
... ... ... ... ... ... ... ... ... ... ... ... ... ...
355 61 Sea Surface all | Zhang Surface_Freshwater Ocean_Surface_Water 3.210394 -19.030002 -2.794831 -1.0 True 1027.531967 0.740818 4154.920691 47.156730
356 47 Sea Surface all | Zhang Surface_Freshwater Coast_Surface_Water 3.554319 -23.551460 -2.733908 -1.0 True 1302.585757 0.539578 9481.499850 12.343862
357 23 Sea Surface all | Zhang Coast_Surface_Water Ocean_Surface_Water 4.112485 -31.867982 -3.125205 -1.0 True 1142.043586 0.902573 3158.382174 79.694563
358 63 Sea Surface all | Zhang Surface_Freshwater Ocean_Surface_Water 4.395308 -36.544219 -3.319479 -1.0 True 1142.043586 0.902573 3158.382174 79.694563
359 37 Sea Surface all | Zhang Coast_Surface_Water Ocean_Surface_Water 4.651851 -41.054845 -3.557464 -1.0 True 1052.671922 0.811533 3073.415520 14.554329

360 rows × 13 columns

In [17]:
# Save results to csv
combined_df.to_csv("UTOPIA_paper_results.csv", index=False)

Top 20 best fitting results for each observed dataset

In [35]:
# Read data from CSV if needed
combined_results = pd.read_csv("UTOPIA_paper_results.csv")
df=combined_results.copy()
In [37]:
combined_results_shorted=df.sort_values("RMSE", ascending=True)
combined_results_shorted
Out[37]:
Case Observed_dataset Emission_Compartment Target_Compartment RMSE R2 Slope Spearman_r Pass_Spearman MPdensity_kg_m3 FI t_half_deg_free t_frag_gen_FreeSurfaceWater
220 6 Sea Surface all | Isobe L2 Surface_Freshwater Coast_Surface_Water 0.192740 0.540131 -0.926349 -1.0 True 938.199911 0.224775 1827.090958 58.014555
240 6 Sea Surface all | Isobe L3 Surface_Freshwater Coast_Surface_Water 0.196303 0.512105 -0.926349 -1.0 True 938.199911 0.224775 1827.090958 58.014555
120 97 Fragments in sediment | Eo Surface_Freshwater Sediment_Coast 0.210465 0.830557 -1.757989 -1.0 True 1052.671922 0.811533 3073.415520 14.554329
121 85 Fragments in sediment | Eo Surface_Freshwater Sediment_Coast 0.219214 0.816177 -1.605927 -1.0 True 1067.147583 0.814583 7649.971822 27.484251
260 26 Sea Surface all | Isobe L4 Surface_Freshwater Ocean_Surface_Water 0.219473 0.496743 -1.260351 -1.0 True 938.199911 0.224775 1827.090958 58.014555
... ... ... ... ... ... ... ... ... ... ... ... ... ...
219 77 Sea Surface all | Isobe L1 Coast_Surface_Water Ocean_Surface_Water 4.229001 -103.626180 -3.557464 -1.0 True 1052.671922 0.811533 3073.415520 14.554329
238 23 Sea Surface all | Isobe L2 Surface_Freshwater Ocean_Surface_Water 4.317504 -229.758353 -3.319479 -1.0 True 1142.043586 0.902573 3158.382174 79.694563
358 63 Sea Surface all | Zhang Surface_Freshwater Ocean_Surface_Water 4.395308 -36.544219 -3.319479 -1.0 True 1142.043586 0.902573 3158.382174 79.694563
239 77 Sea Surface all | Isobe L2 Coast_Surface_Water Ocean_Surface_Water 4.567080 -257.207700 -3.557464 -1.0 True 1052.671922 0.811533 3073.415520 14.554329
359 37 Sea Surface all | Zhang Coast_Surface_Water Ocean_Surface_Water 4.651851 -41.054845 -3.557464 -1.0 True 1052.671922 0.811533 3073.415520 14.554329

360 rows × 13 columns

In [39]:
from utopia.monte_carlo.montecarlo_analysis_paper import run_and_plot_top_results
run_and_plot_top_results(combined_results_shorted[0:10],data_data, config_data)
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [40]:
import seaborn as sns
import matplotlib.pyplot as plt

# Correlation heatmap for the top results
corr = combined_results_shorted[0:19][["MPdensity_kg_m3", "FI", "t_half_deg_free", "t_frag_gen_FreeSurfaceWater"]].corr()

plt.figure(figsize=(8,6))
sns.heatmap(corr, annot=True, cmap="coolwarm", center=0)
plt.title("Correlation matrix (Top 20 best fits)")
plt.show()
No description has been provided for this image
In [42]:
# Pair-wise relationships for the top results
sns.pairplot(
    combined_results_shorted[0:19],
    vars=["MPdensity_kg_m3", "FI", "t_half_deg_free", "t_frag_gen_FreeSurfaceWater"],
    hue="Target_Compartment",
    corner=True
)
plt.suptitle("Parameter relationships for best-fitting runs", y=1.02)
plt.show()
No description has been provided for this image

After the model has ben run recover results from csv and load them again

In [5]:
# Read data from CSV if needed
combined_results = pd.read_csv("UTOPIA_paper_results.csv")
df=combined_results.copy()
In [6]:
combined_results_shorted=df.sort_values("RMSE", ascending=True)
In [8]:
combined_results_shorted[0:20]
Out[8]:
Case Observed_dataset Emission_Compartment Target_Compartment RMSE R2 Slope Spearman_r Pass_Spearman MPdensity_kg_m3 FI t_half_deg_free t_frag_gen_FreeSurfaceWater
220 6 Sea Surface all | Isobe L2 Surface_Freshwater Coast_Surface_Water 0.192740 0.540131 -0.926349 -1.0 True 938.199911 0.224775 1827.090958 58.014555
240 6 Sea Surface all | Isobe L3 Surface_Freshwater Coast_Surface_Water 0.196303 0.512105 -0.926349 -1.0 True 938.199911 0.224775 1827.090958 58.014555
120 97 Fragments in sediment | Eo Surface_Freshwater Sediment_Coast 0.210465 0.830557 -1.757989 -1.0 True 1052.671922 0.811533 3073.415520 14.554329
121 85 Fragments in sediment | Eo Surface_Freshwater Sediment_Coast 0.219214 0.816177 -1.605927 -1.0 True 1067.147583 0.814583 7649.971822 27.484251
260 26 Sea Surface all | Isobe L4 Surface_Freshwater Ocean_Surface_Water 0.219473 0.496743 -1.260351 -1.0 True 938.199911 0.224775 1827.090958 58.014555
200 26 Sea Surface all | Isobe L1 Surface_Freshwater Ocean_Surface_Water 0.219608 0.717863 -1.260351 -1.0 True 938.199911 0.224775 1827.090958 58.014555
122 95 Fragments in sediment | Eo Surface_Freshwater Sediment_Coast 0.220993 0.813182 -1.619336 -1.0 True 1266.860208 0.753409 4509.321025 33.637734
241 66 Sea Surface all | Isobe L3 Coast_Surface_Water Ocean_Surface_Water 0.225292 0.357365 -0.761238 -1.0 True 938.199911 0.224775 1827.090958 58.014555
123 81 Fragments in sediment | Eo Surface_Freshwater Sediment_Coast 0.226836 0.803171 -1.555892 -1.0 True 1027.531967 0.740818 4154.920691 47.156730
261 6 Sea Surface all | Isobe L4 Surface_Freshwater Coast_Surface_Water 0.228836 0.452885 -0.926349 -1.0 True 938.199911 0.224775 1827.090958 58.014555
124 91 Fragments in sediment | Eo Surface_Freshwater Sediment_Coast 0.240624 0.778517 -1.524742 -1.0 True 1193.888212 0.679468 7014.614289 66.504082
20 41 Sea Surface all | Cai Coast_Surface_Water Coast_Surface_Water 0.241146 0.833343 -1.488332 -1.0 True 1027.531967 0.740818 4154.920691 47.156730
320 66 Sea Surface Fibers | Song Surface_Freshwater Ocean_Surface_Water 0.242450 0.341708 -1.260351 -1.0 True 938.199911 0.224775 1827.090958 58.014555
140 83 Fibers in sediment | Eo Surface_Freshwater Sediment_Coast 0.246943 -0.238814 -1.236710 -1.0 True 1142.043586 0.902573 3158.382174 79.694563
221 66 Sea Surface all | Isobe L2 Coast_Surface_Water Ocean_Surface_Water 0.248879 0.233221 -0.761238 -1.0 True 938.199911 0.224775 1827.090958 58.014555
242 26 Sea Surface all | Isobe L3 Surface_Freshwater Ocean_Surface_Water 0.272301 0.061204 -1.260351 -1.0 True 938.199911 0.224775 1827.090958 58.014555
201 6 Sea Surface all | Isobe L1 Surface_Freshwater Coast_Surface_Water 0.273270 0.563134 -0.926349 -1.0 True 938.199911 0.224775 1827.090958 58.014555
321 46 Sea Surface Fibers | Song Surface_Freshwater Coast_Surface_Water 0.274691 0.154986 -0.926349 -1.0 True 938.199911 0.224775 1827.090958 58.014555
80 46 Fragments in water | Eo Surface_Freshwater Bulk_Freshwater 0.280510 0.837037 -1.644561 -1.0 True 938.199911 0.224775 1827.090958 58.014555
180 66 Fresh water sediments | Imhof Impacted_Soil_Surface Surface_Freshwater 0.284774 0.219064 -2.776208 -1.0 True 938.199911 0.224775 1827.090958 58.014555
In [14]:
import seaborn as sns
import matplotlib.pyplot as plt

# Correlation heatmap for the top results
corr = combined_results_shorted[0:19][["MPdensity_kg_m3", "FI", "t_half_deg_free", "t_frag_gen_FreeSurfaceWater"]].corr()

plt.figure(figsize=(8,6))
sns.heatmap(corr, annot=True, cmap="coolwarm", center=0)
plt.title("Correlation matrix (Top 20 best fits)")
plt.show()
No description has been provided for this image

CONTINUE HERE

In [ ]:
# Write up conclusions and next steps

# Best fits corresponds to 2 archetypical types of plastic:
# 1. Low density plastic (LDP) provides best fits to the monitoring data when framgentation index is low (more erosive fragmentation) and and disintegration half-life is short. Fragmentation timescale seems to not play a significant role according to the correlation matrix.
# 2. High density plastic (HDP), provides best fits when fragmentation index is high (more explosive fragmentation) and disintegration half-life is long. Fragmentation timescale seems to not play a significant role according to the correlation matrix.

# We will run scenarios for the two archetipycal plastics and compare results to the articles data to plot best fits against observed data.
In [ ]:
# SET UP SCENARIOS FOR THE TWO ARCHETYPICAL PLASTICS
# 1. Low density plastic (LDP) provides best fits to the monitoring data when framgentation index is low (more erosive fragmentation) and and disintegration half-life is short. Fragmentation timescale seems to not play a significant role according to the correlation matrix.

Run model for Low density polymer (LDP) scenario derived from MC

In [44]:
# Set up scenario simulation for LDP and HDP
from utopia.utopia import utopiaModel
# Define modifications (follow the structure provided in the default configuration data (data_data))
modifications = {
    "MPdensity_kg_m3": 940,
    "MP_composition": "LDP",
    'FI': 0.2,
    "t_half_deg_free": 2000,
    "t_frag_gen_FreeSurfaceWater": 50
}
In [45]:
LDP_data=data_data.copy()
LDP_data["MPdensity_kg_m3"]= modifications["MPdensity_kg_m3"]
LDP_data["MP_composition"]= modifications["MP_composition"]
LDP_data["FI"]= modifications["FI"]
LDP_data["t_half_deg_free"]= modifications["t_half_deg_free"]
LDP_data["t_frag_gen_FreeSurfaceWater"]= modifications["t_frag_gen_FreeSurfaceWater"]    
LDP_data
Out[45]:
{'MPdensity_kg_m3': 940,
 'MP_composition': 'LDP',
 'shape': 'sphere',
 'MP_form': 'freeMP',
 'FI': 0.2,
 't_half_deg_free': 2000,
 'heter_deg_factor': 10,
 'biof_deg_factor': 0.5,
 'factor_deepWater_soilSurface': 10,
 'factor_sediment': 100,
 't_frag_gen_FreeSurfaceWater': 50,
 'biof_frag_factor': 2,
 'heter_frag_factor': 100,
 'emiss_dict_g_s': {'Ocean_Surface_Water': {'a': 0,
   'b': 0,
   'c': 0,
   'd': 0,
   'e': 100},
  'Ocean_Mixed_Water': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Ocean_Column_Water': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Coast_Surface_Water': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Coast_Column_Water': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Surface_Freshwater': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Bulk_Freshwater': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Sediment_Freshwater': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Sediment_Ocean': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Sediment_Coast': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Beaches_Soil_Surface': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Beaches_Deep_Soil': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Background_Soil_Surface': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Background_Soil': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Impacted_Soil_Surface': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Impacted_Soil': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Air': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0}}}
In [52]:
import pandas as pd
from utopia.utopia import utopiaModel
from utopia.results_processing.process_results import *
from scipy.stats import spearmanr
from utopia.monte_carlo.montecarlo_analysis_paper import extract_log_rel_abundance
from utopia.monte_carlo.montecarlo_analysis_paper import plot_obs_vs_model_with_metrics_True


# Run the model for each emission scenario and target compartment
LDP_simulations_results_all={}
for art in overlay_emission_scenarios.keys():
    print(f"Running Monte Carlo analysis for article: {art}")
    LDP_simulations_results=[]
    for comp in overlay_emission_scenarios[art]:
        # Set emissions to that compartment and include it in base_data file
        LDP_data["emiss_dict_g_s"]= set_emission(LDP_data["emiss_dict_g_s"].copy(), comp, "e", 100)
        for comp_T in overlay_compartments_mapping[art]:
            emission_comp=comp
            target_comp=comp_T
            model = utopiaModel(config=config_data, data=LDP_data)
            model.run()
            processor = ResultsProcessor(model)  # Custom processor to handle results
            processor.estimate_flows()
            processor.generate_flows_dict()
            processor.process_results()
            processor.extract_results_by_compartment()
            df = processor.results_by_comp
            df2 = processor.Results_extended
            # processor.estimate_exposure_indicators()

            # Process model outputs into log-relative abundances per size fraction and compare with observed data
            observed_file = "../src/utopia/data/observed_data_long.xlsx"

            observed_df = pd.read_excel(observed_file)

            observed_df = observed_df.rename(columns={
            "dataset identifier": "Dataset",
            "Article name": "Article",
            "log‑transformed size": "log_Size",
            "log‑transformed abundance": "log_Abundance",
        }
    )
            obs_subset = observed_df[observed_df["Article"] == art]
            x_obs_all = obs_subset["log_Size"].astype(float).values
            y_obs_all = obs_subset["log_Abundance"].astype(float).values

            if len(x_obs_all) > 2:
                slope_obs, intercept_obs = np.polyfit(x_obs_all, y_obs_all, 1)
            else:
                slope_obs, intercept_obs = np.nan, np.nan

            result = {}

            # comp_relative_abundance_resultsaccording to target compartment set in the input parameters

            # Exclude size bins that are not withing the observed data range (0.5 and 5 um)
            excluded_sizes = [0.5, 5]
            filtered_Results = df2[~df2["Size_Fraction_um"].isin(excluded_sizes)]
            rel_abun = extract_log_rel_abundance(
                filtered_Results,
                compartment=target_comp,
                value_col="number_of_particles",
            )

            if rel_abun.empty:
                # fill with NaNs
                result.update(
                    {
                        "Spearman_r": np.nan,
                        "Spearman_p": np.nan,
                        "Pass_Spearman": False,
                        "RMSE": np.nan,
                        "R_squared": np.nan,
                        "Model_slope": np.nan,
                        "Model_intercept": np.nan,
                        "Target_compartment": target_comp,
                        "Emission_compartment": emission_comp,
                    }
                )

            else:

                x_mod_all = rel_abun["log_size"].values
                y_mod_all = rel_abun["log_rel_abundance"].values

                # Spearman correlation
                r_value, p_value = spearmanr(x_mod_all, y_mod_all)

                spearman_threshold = -1

                # Initialize metrics
                rmse, r2, slope_mod, intercept_mod = np.nan, np.nan, np.nan, np.nan
                if np.isnan(r_value):
                    pass_spearman = False
                elif (r_value) == spearman_threshold:
                    pass_spearman = True
                else:
                    pass_spearman = False

                # Compute RMSE, R², slope, intercept only if threshold passed

                if pass_spearman == True and len(x_mod_all) > 2 and len(x_obs_all) > 2:
                    slope_mod, intercept_mod = np.polyfit(x_mod_all, y_mod_all, 1)

                    # Align with observed range
                    x_min = max(x_obs_all.min(), x_mod_all.min())
                    x_max = min(x_obs_all.max(), x_mod_all.max())
                    mask_obs = (x_obs_all >= x_min) & (x_obs_all <= x_max)
                    x_obs_filt = x_obs_all[mask_obs]
                    y_obs_filt = y_obs_all[mask_obs]

                    if len(x_obs_filt) > 2:
                        pred_y = slope_mod * x_obs_filt + intercept_mod
                        ss_res = np.sum((y_obs_filt - pred_y) ** 2)
                        ss_tot = np.sum((y_obs_filt - np.mean(y_obs_filt)) ** 2)
                        r2 = 1 - ss_res / ss_tot if ss_tot > 0 else np.nan
                        rmse = np.sqrt(ss_res / len(x_obs_filt))

                        # Plot observed vs model with metrics only if spearman test is true
                        plot_obs_vs_model_with_metrics_True(
                            x_obs_all,
                            y_obs_all,
                            x_mod_all,
                            y_mod_all,
                            comp_T,
                            art,
                            rmse,
                            r2,
                            MP_density=model.MPdensity_kg_m3,
                            FI=model.FI,
                            t_half_deg=model.t_half_deg_free,
                            t_frag=model.t_frag_gen_FreeSurfaceWater,
                        )

                        # Store all metrics in result dict
                        result.update(
                            {
                                "Spearman_r": r_value,
                                "Spearman_p": p_value,
                                "Pass_Spearman": pass_spearman,
                                "RMSE": rmse,
                                "R_squared": r2,
                                "Model_slope": slope_mod,
                                "Model_intercept": intercept_mod,
                                "Target_compartment": target_comp,
                                "Emission_compartment": emission_comp,
                            }
                        )
                    else:
                        # If not enough points to compute metrics, store NaNs
                        result.update(
                            {
                                "Spearman_r": np.nan,
                                "Spearman_p": np.nan,
                                "Pass_Spearman": False,
                                "RMSE": np.nan,
                                "R_squared": np.nan,
                                "Model_slope": np.nan,
                                "Model_intercept": np.nan,
                                "Target_compartment": target_comp,
                                "Emission_compartment": emission_comp,
                            }
                        )
                else:
                    # Store all metrics in result dict
                    result.update(
                        {
                            "Spearman_r": np.nan,
                            "Spearman_p": np.nan,
                            "Pass_Spearman": False,
                            "RMSE": np.nan,
                            "R_squared": np.nan,
                            "Model_slope": np.nan,
                            "Model_intercept": np.nan,
                            "Target_compartment": target_comp,
                            "Emission_compartment": emission_comp,
                        }
                    )
            LDP_simulations_results.append(result)
    LDP_simulations_results_all[art]=LDP_simulations_results    
                

            
            
Running Monte Carlo analysis for article: Sea Sediment | Bergmann
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running Monte Carlo analysis for article: Sea Surface all | Cai
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface Fragments | Enders
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface Fibers | Enders
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fragments in water | Eo
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fibers in water | Eo
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fragments in sediment | Eo
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running Monte Carlo analysis for article: Fibers in sediment | Eo
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running Monte Carlo analysis for article: Sea Surface all | Erni-Cassola
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fresh water sediments | Imhof
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Isobe L1
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Isobe L2
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Isobe L3
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Isobe L4
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: FP all | Scheurer
No description has been provided for this image
c:\Users\PradoDomercq\AppData\Local\miniconda3\envs\utopia_envP11\Lib\site-packages\pandas\core\arraylike.py:402: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
Running Monte Carlo analysis for article: Sea Surface Fragments | Song
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface Fibers | Song
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Zhang
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [ ]:
LDP_simulations_results_all
In [53]:
# Flatten it into a list of rows
rows = []
for article, records in LDP_simulations_results_all.items():
    for record in records:
        record["article"] = article  # Add outer key as a column
        rows.append(record)

# Create DataFrame
df = pd.DataFrame(rows)

# 👇 Drop rows with any NaN values
df_clean = df.dropna()

# Reorder columns (optional)
cols = ["article"] + [c for c in df_clean .columns if c != "article"]
df_clean_LDP  = df_clean [cols]
In [54]:
LDP_correlations_shorted=df_clean_LDP.sort_values("RMSE", ascending=True)
LDP_correlations_shorted.head(20)
Out[54]:
article Spearman_r Spearman_p Pass_Spearman RMSE R_squared Model_slope Model_intercept Target_compartment Emission_compartment
52 Sea Surface all | Isobe L2 -1.0 0.0 True 0.190007 0.553078 -0.917455 3.381548 Coast_Surface_Water Surface_Freshwater
56 Sea Surface all | Isobe L3 -1.0 0.0 True 0.191875 0.533865 -0.917455 3.381548 Coast_Surface_Water Surface_Freshwater
49 Sea Surface all | Isobe L1 -1.0 0.0 True 0.214804 0.730070 -1.235674 4.232543 Ocean_Surface_Water Surface_Freshwater
61 Sea Surface all | Isobe L4 -1.0 0.0 True 0.214970 0.517181 -1.235674 4.232543 Ocean_Surface_Water Surface_Freshwater
59 Sea Surface all | Isobe L3 -1.0 0.0 True 0.235090 0.300253 -0.753680 3.025382 Ocean_Surface_Water Coast_Surface_Water
60 Sea Surface all | Isobe L4 -1.0 0.0 True 0.236564 0.415310 -0.917455 3.381548 Coast_Surface_Water Surface_Freshwater
57 Sea Surface all | Isobe L3 -1.0 0.0 True 0.253886 0.183888 -1.235674 4.232543 Ocean_Surface_Water Surface_Freshwater
73 Sea Surface Fibers | Song -1.0 0.0 True 0.257249 0.258891 -1.235674 4.232543 Ocean_Surface_Water Surface_Freshwater
55 Sea Surface all | Isobe L2 -1.0 0.0 True 0.261469 0.153687 -0.753680 3.025382 Ocean_Surface_Water Coast_Surface_Water
53 Sea Surface all | Isobe L2 -1.0 0.0 True 0.272891 0.078126 -1.235674 4.232543 Ocean_Surface_Water Surface_Freshwater
47 Fresh water sediments | Imhof -1.0 0.0 True 0.272997 0.282320 -2.766529 6.521509 Surface_Freshwater Impacted_Soil_Surface
48 Sea Surface all | Isobe L1 -1.0 0.0 True 0.283553 0.529637 -0.917455 3.381548 Coast_Surface_Water Surface_Freshwater
22 Fragments in water | Eo -1.0 0.0 True 0.286008 0.830587 -1.642383 4.629835 Bulk_Freshwater Surface_Freshwater
72 Sea Surface Fibers | Song -1.0 0.0 True 0.291413 0.048971 -0.917455 3.381548 Coast_Surface_Water Surface_Freshwater
63 Sea Surface all | Isobe L4 -1.0 0.0 True 0.324975 -0.103392 -0.753680 3.025382 Ocean_Surface_Water Coast_Surface_Water
77 Sea Surface all | Zhang -1.0 0.0 True 0.397532 0.692880 -1.235674 4.232543 Ocean_Surface_Water Surface_Freshwater
76 Sea Surface all | Zhang -1.0 0.0 True 0.401689 0.686423 -0.917455 3.381548 Coast_Surface_Water Surface_Freshwater
51 Sea Surface all | Isobe L1 -1.0 0.0 True 0.404384 0.043350 -0.753680 3.025382 Ocean_Surface_Water Coast_Surface_Water
19 Sea Surface Fibers | Enders -1.0 0.0 True 0.415345 -0.105149 -0.753680 3.025382 Ocean_Surface_Water Coast_Surface_Water
16 Sea Surface Fibers | Enders -1.0 0.0 True 0.429575 -0.182169 -0.743555 3.010753 Coast_Surface_Water Ocean_Surface_Water

Run model for high density polymer (HDP) scenario derived from MC

In [55]:
# Define modifications (follow the structure provided in the default configuration data (data_data))
modifications_HDP = {
    "MPdensity_kg_m3": 1150,
    "MP_composition": "LDP",
    'FI': 0.8,
    "t_half_deg_free": 4000,
    "t_frag_gen_FreeSurfaceWater": 50
}
In [56]:
HDP_data=data_data.copy()
HDP_data["MPdensity_kg_m3"]= modifications_HDP["MPdensity_kg_m3"]
HDP_data["MP_composition"]= modifications_HDP["MP_composition"]
HDP_data["FI"]= modifications_HDP["FI"]
HDP_data["t_half_deg_free"]= modifications_HDP["t_half_deg_free"]
HDP_data["t_frag_gen_FreeSurfaceWater"]= modifications_HDP["t_frag_gen_FreeSurfaceWater"]    
HDP_data
Out[56]:
{'MPdensity_kg_m3': 1150,
 'MP_composition': 'LDP',
 'shape': 'sphere',
 'MP_form': 'freeMP',
 'FI': 0.8,
 't_half_deg_free': 4000,
 'heter_deg_factor': 10,
 'biof_deg_factor': 0.5,
 'factor_deepWater_soilSurface': 10,
 'factor_sediment': 100,
 't_frag_gen_FreeSurfaceWater': 50,
 'biof_frag_factor': 2,
 'heter_frag_factor': 100,
 'emiss_dict_g_s': {'Ocean_Surface_Water': {'a': 0,
   'b': 0,
   'c': 0,
   'd': 0,
   'e': 100},
  'Ocean_Mixed_Water': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Ocean_Column_Water': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Coast_Surface_Water': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Coast_Column_Water': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Surface_Freshwater': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Bulk_Freshwater': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Sediment_Freshwater': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Sediment_Ocean': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Sediment_Coast': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Beaches_Soil_Surface': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Beaches_Deep_Soil': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Background_Soil_Surface': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Background_Soil': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Impacted_Soil_Surface': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Impacted_Soil': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0},
  'Air': {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0}}}
In [58]:
# Run the model for each emission scenario and target compartment
HDP_simulations_results_all={}
for art in overlay_emission_scenarios.keys():
    print(f"Running Monte Carlo analysis for article: {art}")
    HDP_simulations_results=[]
    for comp in overlay_emission_scenarios[art]:
        # Set emissions to that compartment and include it in base_data file
        HDP_data["emiss_dict_g_s"]= set_emission(HDP_data["emiss_dict_g_s"].copy(), comp, "e", 100)
        for comp_T in overlay_compartments_mapping[art]:
            emission_comp=comp
            target_comp=comp_T
            model = utopiaModel(config=config_data, data=HDP_data)
            model.run()
            processor = ResultsProcessor(model)  # Custom processor to handle results
            processor.estimate_flows()
            processor.generate_flows_dict()
            processor.process_results()
            processor.extract_results_by_compartment()
            df = processor.results_by_comp
            df2 = processor.Results_extended
            # processor.estimate_exposure_indicators()

            # Process model outputs into log-relative abundances per size fraction and compare with observed data
            observed_file = "../src/utopia/data/observed_data_long.xlsx"

            observed_df = pd.read_excel(observed_file)

            observed_df = observed_df.rename(columns={
            "dataset identifier": "Dataset",
            "Article name": "Article",
            "log‑transformed size": "log_Size",
            "log‑transformed abundance": "log_Abundance",
        }
    )
            obs_subset = observed_df[observed_df["Article"] == art]
            x_obs_all = obs_subset["log_Size"].astype(float).values
            y_obs_all = obs_subset["log_Abundance"].astype(float).values

            if len(x_obs_all) > 2:
                slope_obs, intercept_obs = np.polyfit(x_obs_all, y_obs_all, 1)
            else:
                slope_obs, intercept_obs = np.nan, np.nan

            result = {}

            # comp_relative_abundance_resultsaccording to target compartment set in the input parameters

            # Exclude size bins that are not withing the observed data range (0.5 and 5 um)
            excluded_sizes = [0.5, 5]
            filtered_Results = df2[~df2["Size_Fraction_um"].isin(excluded_sizes)]
            rel_abun = extract_log_rel_abundance(
                filtered_Results,
                compartment=target_comp,
                value_col="number_of_particles",
            )

            if rel_abun.empty:
                # fill with NaNs
                result.update(
                    {
                        "Spearman_r": np.nan,
                        "Spearman_p": np.nan,
                        "Pass_Spearman": False,
                        "RMSE": np.nan,
                        "R_squared": np.nan,
                        "Model_slope": np.nan,
                        "Model_intercept": np.nan,
                        "Target_compartment": target_comp,
                        "Emission_compartment": emission_comp,
                    }
                )

            else:

                x_mod_all = rel_abun["log_size"].values
                y_mod_all = rel_abun["log_rel_abundance"].values

                # Spearman correlation
                r_value, p_value = spearmanr(x_mod_all, y_mod_all)

                spearman_threshold = -1

                # Initialize metrics
                rmse, r2, slope_mod, intercept_mod = np.nan, np.nan, np.nan, np.nan
                if np.isnan(r_value):
                    pass_spearman = False
                elif (r_value) == spearman_threshold:
                    pass_spearman = True
                else:
                    pass_spearman = False

                # Compute RMSE, R², slope, intercept only if threshold passed

                if pass_spearman == True and len(x_mod_all) > 2 and len(x_obs_all) > 2:
                    slope_mod, intercept_mod = np.polyfit(x_mod_all, y_mod_all, 1)

                    # Align with observed range
                    x_min = max(x_obs_all.min(), x_mod_all.min())
                    x_max = min(x_obs_all.max(), x_mod_all.max())
                    mask_obs = (x_obs_all >= x_min) & (x_obs_all <= x_max)
                    x_obs_filt = x_obs_all[mask_obs]
                    y_obs_filt = y_obs_all[mask_obs]

                    if len(x_obs_filt) > 2:
                        pred_y = slope_mod * x_obs_filt + intercept_mod
                        ss_res = np.sum((y_obs_filt - pred_y) ** 2)
                        ss_tot = np.sum((y_obs_filt - np.mean(y_obs_filt)) ** 2)
                        r2 = 1 - ss_res / ss_tot if ss_tot > 0 else np.nan
                        rmse = np.sqrt(ss_res / len(x_obs_filt))

                        # Plot observed vs model with metrics only if spearman test is true
                        plot_obs_vs_model_with_metrics_True(
                            x_obs_all,
                            y_obs_all,
                            x_mod_all,
                            y_mod_all,
                            comp_T,
                            art,
                            rmse,
                            r2,
                            MP_density=model.MPdensity_kg_m3,
                            FI=model.FI,
                            t_half_deg=model.t_half_deg_free,
                            t_frag=model.t_frag_gen_FreeSurfaceWater,
                        )

                        # Store all metrics in result dict
                        result.update(
                            {
                                "Spearman_r": r_value,
                                "Spearman_p": p_value,
                                "Pass_Spearman": pass_spearman,
                                "RMSE": rmse,
                                "R_squared": r2,
                                "Model_slope": slope_mod,
                                "Model_intercept": intercept_mod,
                                "Target_compartment": target_comp,
                                "Emission_compartment": emission_comp,
                            }
                        )
                    else:
                        # If not enough points to compute metrics, store NaNs
                        result.update(
                            {
                                "Spearman_r": np.nan,
                                "Spearman_p": np.nan,
                                "Pass_Spearman": False,
                                "RMSE": np.nan,
                                "R_squared": np.nan,
                                "Model_slope": np.nan,
                                "Model_intercept": np.nan,
                                "Target_compartment": target_comp,
                                "Emission_compartment": emission_comp,
                            }
                        )
                else:
                    # Store all metrics in result dict
                    result.update(
                        {
                            "Spearman_r": np.nan,
                            "Spearman_p": np.nan,
                            "Pass_Spearman": False,
                            "RMSE": np.nan,
                            "R_squared": np.nan,
                            "Model_slope": np.nan,
                            "Model_intercept": np.nan,
                            "Target_compartment": target_comp,
                            "Emission_compartment": emission_comp,
                        }
                    )
            HDP_simulations_results.append(result)
    HDP_simulations_results_all[art]=HDP_simulations_results    
                

            
            
Running Monte Carlo analysis for article: Sea Sediment | Bergmann
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Cai
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface Fragments | Enders
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface Fibers | Enders
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fragments in water | Eo
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fibers in water | Eo
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fragments in sediment | Eo
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fibers in sediment | Eo
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Erni-Cassola
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Fresh water sediments | Imhof
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Isobe L1
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Isobe L2
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Isobe L3
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Isobe L4
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: FP all | Scheurer
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface Fragments | Song
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface Fibers | Song
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Running Monte Carlo analysis for article: Sea Surface all | Zhang
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [59]:
# Flatten it into a list of rows
rows = []
for article, records in HDP_simulations_results_all.items():
    for record in records:
        record["article"] = article  # Add outer key as a column
        rows.append(record)

# Create DataFrame
df2 = pd.DataFrame(rows)

# 👇 Drop rows with any NaN values
df2_clean = df2.dropna()

# Reorder columns (optional)
cols = ["article"] + [c for c in df2_clean .columns if c != "article"]
df2_clean_HDP  = df2_clean [cols]

HDP_correlations_shorted=df2_clean_HDP.sort_values("RMSE", ascending=True)
HDP_correlations_shorted.head(20)
Out[59]:
article Spearman_r Spearman_p Pass_Spearman RMSE R_squared Model_slope Model_intercept Target_compartment Emission_compartment
32 Fragments in sediment | Eo -1.0 0.0 True 0.241373 0.777135 -1.488925 4.386381 Sediment_Coast Surface_Freshwater
15 Sea Surface Fragments | Enders -1.0 0.0 True 0.407572 0.431465 -3.425203 7.086679 Ocean_Surface_Water Coast_Surface_Water
38 Fibers in sediment | Eo -1.0 0.0 True 0.461916 -3.334500 -1.488925 4.386381 Sediment_Coast Surface_Freshwater
12 Sea Surface Fragments | Enders -1.0 0.0 True 0.469533 0.245464 -2.248370 5.139047 Coast_Surface_Water Ocean_Surface_Water
41 Sea Surface all | Erni-Cassola -1.0 0.0 True 0.545142 -1.071792 -3.425203 7.086679 Ocean_Surface_Water Coast_Surface_Water
43 Sea Surface all | Erni-Cassola -1.0 0.0 True 0.599766 -1.507791 -4.372815 9.205297 Ocean_Surface_Water Impacted_Soil_Surface
42 Sea Surface all | Erni-Cassola -1.0 0.0 True 0.622319 -1.699942 -4.427788 9.287040 Coast_Surface_Water Impacted_Soil_Surface
5 Sea Sediment | Bergmann -1.0 0.0 True 0.779936 -8.965140 -2.544950 6.008366 Sediment_Ocean Coast_Column_Water
3 Sea Sediment | Bergmann -1.0 0.0 True 0.787404 -9.156869 -2.518483 5.963838 Sediment_Ocean Coast_Surface_Water
68 Sea Surface Fragments | Song -1.0 0.0 True 0.801651 -0.195902 -2.118969 4.983485 Coast_Surface_Water Surface_Freshwater
6 Sea Surface all | Cai -1.0 0.0 True 0.818705 -0.920971 -2.118969 4.983485 Coast_Surface_Water Surface_Freshwater
31 Fragments in sediment | Eo -1.0 0.0 True 1.026439 -3.030231 -2.582969 6.059751 Sediment_Ocean Surface_Freshwater
1 Sea Sediment | Bergmann -1.0 0.0 True 1.230411 -23.800792 -1.641612 4.674583 Sediment_Ocean Ocean_Surface_Water
0 Sea Sediment | Bergmann -1.0 0.0 True 1.230878 -23.819628 -1.513833 4.421349 Sediment_Coast Ocean_Surface_Water
4 Sea Sediment | Bergmann -1.0 0.0 True 1.247517 -24.495181 -1.485210 4.381168 Sediment_Coast Coast_Column_Water
2 Sea Sediment | Bergmann -1.0 0.0 True 1.247524 -24.495471 -1.485202 4.381159 Sediment_Coast Coast_Surface_Water
46 Fresh water sediments | Imhof -1.0 0.0 True 1.379896 -17.336091 -4.387324 9.220131 Bulk_Freshwater Impacted_Soil_Surface
47 Fresh water sediments | Imhof -1.0 0.0 True 1.379904 -17.336285 -4.387332 9.220144 Surface_Freshwater Impacted_Soil_Surface
72 Sea Surface Fibers | Song -1.0 0.0 True 1.453456 -22.658010 -2.118969 4.983485 Coast_Surface_Water Surface_Freshwater
29 Fragments in sediment | Eo -1.0 0.0 True 1.511737 -7.742109 -3.661678 8.303263 Sediment_Coast Impacted_Soil_Surface